import request from "@/utils/request";

// 查询生产补料单列表
export function listSupply(query) {
  return request({
    url: "/mes/pro/supply/list",
    method: "get",
    params: query,
  });
}

// 根据工单编号查询所有物料
export function listMaterialInfo(query) {
  return request({
    url: "/mes/pro/supply/product/list",
    method: "get",
    params: query,
  });
}

// 查询生产补料单详细
export function getSupply(id) {
  return request({
    url: "/mes/pro/supply/" + id,
    method: "get",
  });
}
export function getSupplyInfo(id) {
  return request({
    url: "/mes/pro/supply/getProMaterialSupplyInfo/" + id,
    method: "get",
  });
}

// 新增生产补料单
export function addSupply(data) {
  return request({
    url: "/mes/pro/supply",
    method: "post",
    data: data,
  });
}

// 修改生产补料单
export function updateSupply(data) {
  return request({
    url: "/mes/pro/supply",
    method: "put",
    data: data,
  });
}

// 删除生产补料单
export function delSupply(id) {
  return request({
    url: "/mes/pro/supply/" + id,
    method: "delete",
  });
}

// 新增生产补料单及明细
export function addSupplyBatchInfo(data) {
  return request({
    url: "/mes/pro/supply/detail/add",
    method: "post",
    data: data,
  });
}

// 生成领料单
export function supplyProcess(data) {
  return request({
    url: "/mes/pro/supply/supply/process",
    method: "get",
    params: data,
  });
}

export function updateSupplyBatchInfo(data) {
  return request({
    url: "/mes/pro/supply/detail/update",
    method: "post",
    data: data,
  });
}

export function getSupplyApproval(data) {
  return request({
    url: "/mes/pro/approval/process/create",
    method: "post",
    data: data,
  });
}
// 查看审批流信息
export function getApprovalList(id) {
  return request({
    url: "/mes/pro/approval/supply/list/" + id,
    method: "get",
  });
}
// 查看仓库信息
export function getWareHouseList(query) {
  return request({
    url: "/mes/pro/supply/warehouse/list",
    method: "get",
    params: query,
  });
}

// 打印补料单数据列表

export function printSupply(id) {
  return request({
    url: "/mes/pro/supply/detail/listById/" + id,
    method: "get",
  });
}

// 下推

export function pushDownSupply(data) {
  return request({
    url: "/mes/pro/supply/pushDown",
    method: "put",
    data: data,
  });
}
// 确认补料
export function confirmedFeedSupply(data) {
  return request({
    url: "/mes/pro/supply/confirmedFeed",
    method: "put",
    data: data,
  });
}

export function saveToErp(id) {
  return request({
    url: "/mes/k3cloud/api/proMaterialSupplyToErp/saveToErp/" + id,
    method: "get",
  });
}
